package stats.security.services.impl;

import org.jboss.logging.Logger;
import org.springframework.transaction.annotation.Transactional;

import stats.security.dao.SecurityDao;
import stats.security.dto.User;
import stats.security.services.SecurityService;

public class SecurityServiceImpl implements SecurityService {

    private Logger log = Logger.getLogger(getClass());
    private String adminEmail = "vladk1976@gmail.com";
    private SecurityDao securityDao;

    public void setSecurityDao(SecurityDao securityDao) {
        this.securityDao = securityDao;
    }

    @Override
    public User login(String email, String password) {
        return null;
    }
 
    public void autoconfigure() {
        User admin = securityDao.loadUserByName("admin");
        if (admin == null) {
            admin = new User();
            admin.setName("admin");
            admin.setEmail(adminEmail);
            admin.setPassword("admin");
          // securityDao.saveUser(admin);
            log.info("Initial admin user created");
        }
    }

}
